home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / bash-1.12 / dist / general.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-21  |  1.9 KB  |  83 lines

  1. /* general.h -- defines that everybody likes to use. */
  2.  
  3. #if !defined (_GENERAL_)
  4. #define _GENERAL_
  5.  
  6. #if !defined (NULL)
  7. #define NULL 0x0
  8. #endif
  9.  
  10. #ifndef savestring
  11. #define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
  12. #endif
  13.  
  14. #ifndef whitespace
  15. #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
  16. #endif
  17.  
  18. #ifndef digit
  19. #define digit(c)  ((c) >= '0' && (c) <= '9')
  20. #endif
  21.  
  22. #ifndef isletter
  23. #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
  24. #endif
  25.  
  26. #ifndef digit_value
  27. #define digit_value(c) ((c) - '0')
  28. #endif
  29.  
  30. #if !defined (__STDC__)
  31. char *index (), *rindex ();
  32. #endif
  33.  
  34. #ifndef member
  35. #define member(c, s) (int)((c) ? index ((s), (c)) : 0)
  36. #endif
  37.  
  38. /* All structs which contain a `next' field should have that field
  39.    as the first field in the struct.  This means that functions
  40.    can be written to handle the general case for linked lists. */
  41. typedef struct g_list {
  42.   struct g_list *next;
  43. } GENERIC_LIST;
  44.   
  45. /* Here is a generic structure for associating character strings
  46.    with integers.  It is used in the parser for shell tokenization. */
  47. typedef struct {
  48.   char *word;
  49.   int token;
  50. } STRING_INT_ALIST;
  51.  
  52. /* String comparisons that possibly save a function call each. */
  53. #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
  54. #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
  55.  
  56. /* Function pointers can be declared as (Function *)foo. */
  57. #if !defined (__FUNCTION_DEF)
  58. #  define __FUNCTION_DEF
  59. typedef int Function ();
  60. typedef void VFunction ();
  61. #endif /* _FUNCTION_DEF */
  62.  
  63. #if defined (VOID_SIGHANDLER)
  64. #define sighandler void
  65. #else
  66. #define sighandler int
  67. #endif
  68.  
  69. typedef sighandler SigHandler ();
  70.  
  71. #define NOW    ((time_t) time ((time_t *) 0))
  72.  
  73. /* Some defines for calling file status functions. */
  74. #define FS_EXISTS      0x1
  75. #define FS_EXECABLE      0x2
  76. #define FS_EXEC_PREFERRED 0x4
  77. #define FS_EXEC_ONLY      0x8
  78.  
  79. extern char *xmalloc (), *malloc (), *xrealloc (), *realloc ();
  80. extern char *itos ();
  81.  
  82. #endif    /* _GENERAL_ */
  83.